package com.mayisoftware.mayioa.common.api.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 规则作用的对象
 *
 */
public enum RuleTarget
{
    /** 项目角色 */
    PROJCET_ROLE(1, "sys_user_project_role", "SysUser"),
    /** 岗位 */
    USER_POST(2, "sys_hw_level", "SysUser"),
    /** 地域 */
    REGION(3, "sys_user_region", "SysUser"),
    /** 工作年限 */
    WORK_YEAR(4, "plan_work_year", "SysUser"),
    /** 入职年限 */
    JOIN_YEAR(5, "plan_join_year", "SysUser"),
    /** 绩效 */
    ACHIEVEMENTS(6, "plan_achievement_score", "SysUser"),
    /** 特殊贡献 */
    CONTRIBUTION(7, "plan_contribution", "SysUser"),
    /** 计划人数 */
    PLAN_NUM(8, "plan_num", "PlanInfo")
    ;

    private final Integer value;
    private final String type;
    private final String obj;

    RuleTarget(int value, String type, String obj)
    {
        this.value = value;
        this.type = type;
        this.obj = obj;
    }

    public static RuleTarget getRuleEnumByValue(String value){
        for(RuleTarget ruleEnum : RuleTarget.values()){
            if(StringUtils.equals(value, String.valueOf(ruleEnum.value()))){
                return ruleEnum;
            }
        }
        return null;
    }

    public static String getType(int value) {
        RuleTarget[] ruleTargetEnums = values();
        for (RuleTarget ruleTargetEnum : ruleTargetEnums) {
            if (ruleTargetEnum.value()==value) {
                return ruleTargetEnum.type();
            }
        }
        return null;
    }
    public int value()
    {
        return value;
    }
    public String obj()
    {
        return obj;
    }

    public String type()
    {
        return type;
    }
}
